const strUtils = {
    formant(str, arr) {
    let newStr = "";
    let  start  = 0
    for (let item of arr){
        let index =  str.indexOf("{}",start)
        let itemIndex = arr.indexOf(item)
        //index 是找到的当前下标，将当前下标开始+1的参数替换成 item
        let startStr = str.substring(start===0?start:start+1,index)
        //console.log(startStr+item+startEnd)
        if (itemIndex===arr.length-1){
            let endStr = str.substring(index+2,str.length)
            newStr += startStr+item+endStr
        }else{
            newStr += startStr+item
        }
        start = index+1
    }
    return newStr
    },
    indexesOf(arr,flag){
    //遍历元素把满足条件的下标返回出来
    let indexList = []
    for (let index in arr){
        let item = arr[index]
        if (flag(item)){
            indexList.push(Number.parseFloat(index))
        }
    }
    return indexList
}
}
module.exports = strUtils;
